package com.erp.app.util.web;

import javax.servlet.http.HttpSession;

import com.erp.framework.model.delegate.SimpleBaseDelegate;

public class DescriptionUtil {
    public static final String STATUS_MASTER_EMPTY = "";
    public static final String STATUS_MASTER_ACTIVE = "ACTIVE";
    public static final String STATUS_MASTER_INACTIVE = "INACTIVE";

    /** Singleton instance */
    private static DescriptionUtil self = null;

    final public static String SAMPLE_TYPE = "sample";

    protected static SimpleBaseDelegate dg = new SimpleBaseDelegate();

    public String getDesc(HttpSession session, String type, String code) {
        return getDesc(session, type, code, null);
    }

    // static block to instantiate the singleton in a threadsafe way
    static {
        self = new DescriptionUtil();
    }

    /**
     * Private constructor to enforce singleton design pattern
     */
    private DescriptionUtil() {

    }

    /**
     * Enforce singleton method. Returns the instance of this object.
     * 
     * @return the singleton instance of this class
     */
    public static DescriptionUtil getInstance() {
        return self;
    }

    final public static String TYPE_MASTER_STATUS = "masterStatus";

    public String getDesc(HttpSession session, String type, String code, String subCode) {
        String name = "";

        if (type != null) {
            if (TYPE_MASTER_STATUS.equals(type)) {
                name = getMasterStatusDesc(code);
            }
        }
        return name;
    }

    public String getMasterStatusDesc(String status) {

        String name = "";

        if (STATUS_MASTER_ACTIVE.equals(status)) {
            name = "Active";
        } else if (STATUS_MASTER_INACTIVE.equals(status)) {
            name = "Inactive";
        }

        return name;
    }

}
